//
//  LGBreathReportSituationView.m
//  HeartDisease_YHJK
//
//  Created by 1234 on 2025/8/6.
//  训练报告-总体情况

#import "LGBreathReportSituationView.h"

@interface LGBreathReportSituationView()


@end

@implementation LGBreathReportSituationView

- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame{
    self = [super initWithTitle:title frame:frame];
    if (self) {
        self.gradientLayer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        [self createSubView];
    }
    return self;
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    //训练时间
    UIView *iconView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(50), 4, viewPix(14))];
    iconView.backgroundColor = [UIColor colorWithString:@"#77D4C6"];
    iconView.cornerRidus = 2;
    [self addSubview:iconView];
    UILabel *titleLabel = [UILabel lableWithText:@"训练时间" colorString:@"#282828" textFont:LGFontWeight(16, UIFontWeightSemibold) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel.frame = CGRectMake(viewPix(28), kMinY(iconView.frame)-viewPix(4), viewPix(150), viewPix(22));
    [self addSubview:titleLabel];
    //表格
    CGFloat width1 = (Screen_W-viewPix(56))/2.0 - viewPix(11);
    CGFloat width2 = ((Screen_W-viewPix(56))/2.0 + viewPix(11))/2.0;
    UIView *baseView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(76), Screen_W-viewPix(56), viewPix(120))];
    [baseView addBorder:@"#E0E0E0" lineWidth:1 cornerRidus:2];
    [self addSubview:baseView];
    //蓝色背景
    UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_W-viewPix(56), viewPix(40))];
    titleView.backgroundColor = [UIColor colorWithString:@"#F3F9FF"];
    [baseView addSubview:titleView];
    
    //分割线 - H
    NSArray *titleArray = @[@"指标",@"呼吸次数",@"训练时长(分'秒\")"];
    for (NSInteger i=0; i<3; i++) {
        UIView *lineView_H = [[UIView alloc]initWithFrame:CGRectMake(0, viewPix(40)*i, Screen_W-viewPix(56), 1)];
        lineView_H.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
        lineView_H.hidden = (i == 0)?YES:NO;
        [baseView addSubview:lineView_H];
        
        UILabel *titleLabel = [UILabel lableWithText:titleArray[i] colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
        titleLabel.frame = CGRectMake(viewPix(8), viewPix(40)*i, width1-viewPix(16), viewPix(40));
        [baseView addSubview:titleLabel];
    }
    
    //分割线 - V
    UIView *lineView_V1 = [[UIView alloc]initWithFrame:CGRectMake(width1, 0, 1, viewPix(120))];
    lineView_V1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    [baseView addSubview:lineView_V1];
    
    UIView *lineView_V2 = [[UIView alloc]initWithFrame:CGRectMake(width1+width2, 0, 1, viewPix(120))];
    lineView_V2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    [baseView addSubview:lineView_V2];
    
    //标题：计划、记录
    UILabel *titleLabel1 = [UILabel lableWithText:@"计划" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel1.frame = CGRectMake(viewPix(8)+width1, 0, width1-viewPix(16), viewPix(40));
    [baseView addSubview:titleLabel1];
    
    UILabel *titleLabel2 = [UILabel lableWithText:@"结果" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel2.frame = CGRectMake(viewPix(8)+width1+width2, 0, width2-viewPix(16), viewPix(40));
    [baseView addSubview:titleLabel2];
    
    //值
    self.planLabel1.frame = CGRectMake(kMinX(titleLabel1.frame), kMaxY(titleLabel1.frame), width2-viewPix(10), viewPix(40));
    self.planLabel2.frame = CGRectMake(kMinX(titleLabel1.frame), kMaxY(self.planLabel1.frame), width2-viewPix(10), viewPix(40));
    self.resultLabel1.frame = CGRectMake(kMinX(titleLabel2.frame), kMaxY(titleLabel2.frame), width2-viewPix(10), viewPix(40));
    self.resultLabel2.frame = CGRectMake(kMinX(titleLabel2.frame), kMaxY(self.resultLabel1.frame), width2-viewPix(10), viewPix(40));
    [baseView addSubview:self.planLabel1];
    [baseView addSubview:self.planLabel2];
    [baseView addSubview:self.resultLabel1];
    [baseView addSubview:self.resultLabel2];
    
}

-(UILabel *)planLabel1{
    if(!_planLabel1){
        _planLabel1 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _planLabel1;
}

-(UILabel *)planLabel2{
    if(!_planLabel2){
        _planLabel2 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _planLabel2;
}

-(UILabel *)resultLabel1{
    if(!_resultLabel1){
        _resultLabel1 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _resultLabel1;
}

-(UILabel *)resultLabel2{
    if(!_resultLabel2){
        _resultLabel2 = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _resultLabel2;
}

@end
